#pragma once
#include <memory>

template<class T>
public ref class  mng_shared_ptr 
{
public:
	typedef std::tr1::shared_ptr<T> mng_shared_ptr_T;
public:
	mng_shared_ptr()
	{
		ptr = new mng_shared_ptr_T();
	}
	mng_shared_ptr(const mng_shared_ptr_T& val )
	{
		ptr = new mng_shared_ptr_T();
		*ptr = val;
	}
	mng_shared_ptr( T* val )
	{
		ptr = new mng_shared_ptr_T(val);
	}
	~mng_shared_ptr()
	{
		delete ptr;
	}

	mng_shared_ptr<T>^ operator= (const mng_shared_ptr_T& val)
	{
		*ptr	= val;
		return this;
	}  

	mng_shared_ptr_T ToPtr()
	{
		return *ptr;
	}

	operator mng_shared_ptr_T()
	{
		return ToPtr();
	}

	mng_shared_ptr_T operator->()
	{
		return *ptr;
	}
private:
	mng_shared_ptr_T* ptr;
};
